/**
 *  玩家操作的相机
 */
runOnStartup(async runtime => {
    window.addEventListener("minerTick", (e) => {
    })
    window.addEventListener("minerInit", (e) => {
        mh_Camera.PlControlsCamera()
    })
});
cc_Game.mh_Camera = {
    PlControlsCamera: function () {
        this.tagrCam(true)
        var camobjet = runtime.objects.Cam?.getFirstInstance()
        var moveBehavior = camobjet?.behaviors.move
        var camspeed = 100
        cc_Game.mh_Camera.camnintX = camobjet.x
        cc_Game.mh_Camera.caminitY = camobjet.y
        //todo:add keydown event to call move
        // press key movedown
        cc_Game.addEventListener("_keyup", function KEYUP() {
            moveBehavior.moveToPosition(camobjet.x, camobjet.y - camspeed)
        })
        // press key moveup
        cc_Game.addEventListener("_keydown", function KEYDOWN() {
            moveBehavior.moveToPosition(camobjet.x, camobjet.y + camspeed)
        })
    },
    tagrCam: function (bool) {
        //todo:add function in event sheet
        runtime.callFunction("camtage", bool)
    },
    cambackInit: function () {
        var camobjet = runtime.objects.Cam?.getFirstInstance()
        var moveBehavior = camobjet?.behaviors.move
        moveBehavior.moveToPosition(cc_Game.mh_Camera.camnintX, cc_Game.mh_Camera.caminitY)
    }
}

export default mh_Camera